
package org.wangnian.demo02_config_file.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

@Component
// 参数配置的数据类型是一个对象或者数组，这个时候才用 @ConfigurationProperties 会是一个比较好的选择！
// 注意，必须实现 set 方法
@ConfigurationProperties(prefix = "config2")
public class Config2 {
    private String key1 = "default";
    private String key2 = "default";
    private String key3 = "default";


    public void setKey1(String key1) {
        this.key1 = key1;
    }

    public void setKey2(String key2) {
        this.key2 = key2;
    }

    public String getKey1() {
        return key1;
    }

    public String getKey2() {
        return key2;
    }

    public String getKey3() {
        return key3;
    }

    public void setKey3(String key3) {
        this.key3 = key3;
    }

    @Override
    public String toString() {
        return "Config2{" +
                "key1='" + key1 + '\'' +
                ", key2='" + key2 + '\'' +
                ", key3='" + key3 + '\'' +
                '}';
    }
}
